import java.util.*;
import java.util.Random;

public class Process{
PCB pcb;
int randomSize;

//Statistics Gathering
int timeCreated;
int timeTerminated;
int timeInNewQueue;
int timeInReadyQueue;
int timeInWaitingQueue;
int timeInRunningQueue;
int timeInTerminatedQueue;
int timeEnteredQueue;
int currentQueue;//0=New, 1=Ready, 2=Running, 3=Waiting, 4=Terminated

	/**THE PCB IS EQUIVALENT TO THE HEADER**/
	public class PCB{
		int state;
		int p_number=Kernel.totalProcesses++;
		int size, processSize, stackSize=0; 
		int headerSize=2; 
		int burstLength;
		int burstLengthRemaining;
		float p_counter;
		int devicesNeeded[]=new int[7];
		int pageTable [];
		//a 7 by 2 array, the first will be all the devices that the process needs, the second will be the time that it received the device
		int devicesInUse[][]=new int[7][2];
		
		
		public PCB(){
			/**Generate a random size for the Process**/
			Random randomGenerator = new Random();
			int random[]=new int [10];
			for(int i=0;i<9;i++)
			{
				//the +1 ensures that a process will atleast be of size=1
				random[i]=(randomGenerator.nextInt(4750*8)+1);
			}
			//generates a random number between 0 and 524287
			random[9] = (randomGenerator.nextInt(524287*8)+1);
			//picks a size, 90% of the time it will be <3000 and 10% it will be <524288
			randomSize = random[randomGenerator.nextInt(10)];
			/**process size generation ends here**/
			
			pageTable = new int [randomSize/8];
		}
		
		public int[] getPageTable(){
			return pageTable;
		}
	}

   public Process(){
  pcb=new PCB();
  pcb.processSize=randomSize;
//pcb.stackSize;               					DONT FORGET TO CHANGE THIS VALUE
//size is the total size we need to allocate in memory
  pcb.size=pcb.stackSize+pcb.processSize+2;
//burst length will be how many cpu cycles it will need to complete
 ;
    pcb.burstLengthRemaining=pcb.processSize;
    Kernel.writeToLog("process size= " + pcb.processSize+"\nsize = " +pcb.size  );
  System.out.println("process size= " + pcb.processSize+"\nsize = " +pcb.size  );
}//end of Process constructor
public int getSize()
{
return randomSize;
}
public int getPno()
{
return pcb.p_number;
}


}
